package com.java01.file.inputstream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class CopyFile {

	public static void copyFile(File inFile, File outFile) {
		InputStream in = null;
		OutputStream out = null;
		
		try {
			in = new FileInputStream(inFile);
			out = new FileOutputStream(outFile);

			byte[] buf = new byte[1024];
			int len;
			while ((len = in.read(buf)) > 0) {
				out.write(buf, 0, len);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
				}
			}
			if (out != null) {
				try {
					out.close();
				} catch (IOException e) {
				}
			}
		}
	}

	public static void main(String[] args) {
		copyFile(new File("d:\\sqlite.sql"), new File("d:\\kill.sql"));
	}
}